using System;
using Spring.Data.NHibernate.Support;
using Spring.Data.NHibernate;
using NHibernate; 
using NHibernate.Criterion;
using System.Collections.Generic;
using System.Collections;
namespace pos.entity
{
    /// <summary>
    /// Summary description for 商品库存 数据库访问类
    /// </summary>
    public partial  class StorageDao:Dao<Storage>
    {
    	
        public static long SEQID=120;
		 public Storage GetBySeqID(long val)
		 {
		 	dc=DC.Add(Restrictions.Eq("seqID",val));
		 	return (Storage)dao.Execute(__GetByDcDelegate);
		 }
		 public Storage GetByCommodityID(String val)
		 {
		 	dc=DC.Add(Restrictions.Eq("commodityID",val));
		 	return (Storage)dao.Execute(__GetByDcDelegate);
		 }

        protected override Object __AddDelegate(ISession session)
        {
	            Sequence seq = session.Get(typeof(Sequence), SEQID) as Sequence;
            if (seq == null)
                throw new pos.excption.DesignException("Sequence 不存在");
            Storage entity = obj as Storage;
            entity.seqID=seq.sequenceNo++;
           Object rs= session.Save(obj);
           session.Update(seq);
		   return rs;
        }    
    }
}

